package com.czl.module_storehouse.mvp.model;

import com.czl.base.data.bean.tengyun.ReceiveBean;
import com.czl.base.data.net.RetrofitClient;
import com.czl.module_base.bean.ListBean;
import com.czl.module_base.http.HttpResponse;
import com.czl.module_service.system.Constants;
import com.czl.module_storehouse.api.ApiService;

import org.json.JSONObject;

import io.reactivex.Observable;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * @author by xubin,
 * @date on 2022/1/25.
 * PS: Not easy to write code, please indicate.
 */
public class ReceiveHomeModel extends BasicDataModel {

    public Observable<HttpResponse<ListBean<ReceiveBean>>> getNeedDealtReceiveList(int pageNo) {
        JSONObject object = new JSONObject();
        try {
            object.put("companyId", getManageCompanyId());
            object.put("pageNo", pageNo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        String json = object.toString();
        MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
        return RetrofitClient.getInstance().create(ApiService.class).getNeedDealtReceiveList(RequestBody.create(mediaType, json));
    }

    public Observable<HttpResponse<ListBean<ReceiveBean>>> getDealtReceiveList(int pageNo) {
        JSONObject object = new JSONObject();
        try {
            object.put("storehouseId", getStorehouseId());
            object.put("pageNo", pageNo);
            object.put("pageSize", Constants.Params.pageSize);
        } catch (Exception e) {
            e.printStackTrace();
        }
        String json = object.toString();
        MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
        return RetrofitClient.getInstance().create(ApiService.class).getDealtReceiveList(RequestBody.create(mediaType, json));

    }
}
